package com.hopu.bean.shop;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Top10HotShop implements Serializable, Comparable<Top10HotShop>{

    private String sid;
    private String sname;
    private String type;
    private int view;
    private int cart;
    private int parchase;

    public Top10HotShop(String sid, String sname, String type) {
        this.sid = sid;
        this.sname = sname;
        this.type = type;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Top10HotShop that = (Top10HotShop) o;
        return Objects.equals(sid, that.sid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sid);
    }

    @Override
    public int compareTo(Top10HotShop o) {
        if (o.getParchase() == this.getParchase()) {
            if (o.getCart() == this.getCart()) {
                return o.getView() - this.getView();
            } else {
                return o.getCart() - this.getCart();
            }
        } else {
            return o.getParchase() - this.getParchase();
        }
    }
}
